{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "metafile = open('meta.csv')\n",
    "data = []\n",
    "for line in metafile:\n",
    "    attr = line.rstrip().split('\\t')\n",
    "    assert(len(attr) == 9)\n",
    "    name, paper, code, inst, date, p1, p2, p3, p4 = attr\n",
    "    score = float(p1) + float(p2) + float(p3) + float(p4)\n",
    "    item = {'meta': [name, paper, code, inst, date, p1, p2, p3, p4], 'score': score}\n",
    "    data.append(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.sort(key=lambda x: x['score'], reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "rank = 0\n",
    "s = ''\n",
    "for item in data:\n",
    "    name, paper, code, inst, date, p1, p2, p3, p4 = item['meta']\n",
    "    rank += 1\n",
    "    s += '<tr>'\n",
    "    s += '<th scope=\"row\">'\n",
    "    s += '<p>{}</p>'.format(rank)\n",
    "    s += '</th>'\n",
    "    s += '<td style=\"word-break:break-word;\">'\n",
    "    s += name\n",
    "    if len(paper) > 0:\n",
    "        s += '<a href=\"{}\">[paper]</a>'.format(paper)\n",
    "    if len(code) > 0:\n",
    "        s += '<a href=\"{}\">[code]</a>'.format(code)\n",
    "    s += '<br>'\n",
    "    s += '<strong>{}</strong>'.format(inst)\n",
    "    s += '<br>'\n",
    "    s += date\n",
    "    s += '</td>'\n",
    "    s += '<td>{}</td>'.format(p1)\n",
    "    s += '<td>{}</td>'.format(p2)\n",
    "    s += '<td>{}</td>'.format(p3)\n",
    "    s += '<td>{}</td>'.format(p4)\n",
    "    s += '</tr>'\n",
    "    #print(BeautifulSoup(s).prettify())\n",
    "    #htmlfile.write(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<tr><th scope=\"row\"><p>1</p></th><td style=\"word-break:break-word;\">Matching the Blanks<a href=\"https://arxiv.org/abs/1906.03158\">[paper]</a><br><strong>Google Research</strong><br>(Feb 26, 2019)</td><td>93.86</td><td>97.06</td><td>89.20</td><td>94.27</td></tr><tr><th scope=\"row\"><p>2</p></th><td style=\"word-break:break-word;\">Anonymous Pony<br><strong></strong><br>(Jan 17, 2020)</td><td>91.61</td><td>96.01</td><td>86.78</td><td>91.63</td></tr><tr><th scope=\"row\"><p>3</p></th><td style=\"word-break:break-word;\">Anonymous Groundhog<br><strong></strong><br>(Nov 3, 2019)</td><td>90.31</td><td>94.28</td><td>85.48</td><td>90.51</td></tr><tr><th scope=\"row\"><p>4</p></th><td style=\"word-break:break-word;\">Anonymous Python<br><strong></strong><br>(Nov 3, 2019)</td><td>88.30</td><td>95.94</td><td>81.10</td><td>92.67</td></tr><tr><th scope=\"row\"><p>5</p></th><td style=\"word-break:break-word;\">BERT-PAIR<a href=\"https://www.aclweb.org/anthology/D19-1649.pdf\">[paper]</a><a href=\"https://github.com/thunlp/fewrel\">[code]</a><br><strong>THUNLP, Tsinghua University</strong><br>(Nov 3, 2019)</td><td>88.32</td><td>93.22</td><td>80.63</td><td>87.02</td></tr><tr><th scope=\"row\"><p>6</p></th><td style=\"word-break:break-word;\">MLMAN<a href=\"https://arxiv.org/abs/1906.06678\">[paper]</a><a href=\"https://github.com/ZhixiuYe/MLMAN\">[code]</a><br><strong>NEL-SLIP, University of Science and Technology of China</strong><br>(Jan 10, 2019)</td><td>82.98</td><td>92.66</td><td>73.59</td><td>87.29</td></tr><tr><th scope=\"row\"><p>7</p></th><td style=\"word-break:break-word;\">PLATO<br><strong>Primer.ai</strong><br>(Nov 19, 2019)</td><td>82.93</td><td>91.76</td><td>74.41</td><td>85.91</td></tr><tr><th scope=\"row\"><p>8</p></th><td style=\"word-break:break-word;\">Anonymous Rabbit<br><strong></strong><br>(Mar 3, 2020)</td><td>83.47</td><td>92.31</td><td>73.64</td><td>85.30</td></tr><tr><th scope=\"row\"><p>9</p></th><td style=\"word-break:break-word;\">TDCN<br><strong>Anonymous</strong><br>(Jul 23, 2019)</td><td>81.93</td><td>92.08</td><td>72.18</td><td>85.98</td></tr><tr><th scope=\"row\"><p>10</p></th><td style=\"word-break:break-word;\">Prototypical Network (LM-Transformer)<br><strong>LAVIS, University of Applied Sciences RheinMain</strong><br>(Jan 18, 2019)</td><td>81.40</td><td>92.11</td><td>72.51</td><td>86.03</td></tr><tr><th scope=\"row\"><p>11</p></th><td style=\"word-break:break-word;\">LM-ProtoNet (FGM)<br><strong>Anonymous</strong><br>(Feb 15, 2019)</td><td>76.60</td><td>89.31</td><td>65.31</td><td>82.10</td></tr><tr><th scope=\"row\"><p>12</p></th><td style=\"word-break:break-word;\">Prototypical Network (CNN)<br><strong></strong><br></td><td>74.52</td><td>88.40</td><td>62.38</td><td>80.45</td></tr><tr><th scope=\"row\"><p>13</p></th><td style=\"word-break:break-word;\">SNAIL (CNN)<br><strong></strong><br></td><td>67.29</td><td>79.40</td><td>53.28</td><td>68.33</td></tr><tr><th scope=\"row\"><p>14</p></th><td style=\"word-break:break-word;\">Meta Network (CNN)<br><strong></strong><br></td><td>64.46</td><td>80.57</td><td>53.96</td><td>69.23</td></tr><tr><th scope=\"row\"><p>15</p></th><td style=\"word-break:break-word;\">GNN (CNN)<br><strong></strong><br></td><td>66.23</td><td>81.28</td><td>46.27</td><td>64.02</td></tr><tr><th scope=\"row\"><p>16</p></th><td style=\"word-break:break-word;\">kNN (PCNN)<br><strong></strong><br></td><td>60.28</td><td>72.41</td><td>46.15</td><td>59.11</td></tr><tr><th scope=\"row\"><p>17</p></th><td style=\"word-break:break-word;\">kNN (CNN)<br><strong></strong><br></td><td>54.67</td><td>68.77</td><td>41.24</td><td>55.87</td></tr><tr><th scope=\"row\"><p>18</p></th><td style=\"word-break:break-word;\">Finetune (CNN)<br><strong></strong><br></td><td>44.21</td><td>68.66</td><td>27.30</td><td>55.04</td></tr><tr><th scope=\"row\"><p>19</p></th><td style=\"word-break:break-word;\">Finetune (PCNN)<br><strong></strong><br></td><td>45.64</td><td>57.86</td><td>29.65</td><td>37.43</td></tr>\n"
     ]
    }
   ],
   "source": [
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
